<?php
include_once('config/config.php');

$LoginAdmin = $_COOKIE['LoginAdmin'] ? $_COOKIE['LoginAdmin'] : '';

if(empty($LoginAdmin))
{
    ShowMsg('请先登录','login.php');
    exit;
}

$LoginAdminList = all("SELECT * FROM `pre_admin`");

$adminid = '';

foreach($LoginAdminList as $item)
{
    $ReAdmin = md5($item['id'].$item['salt']);

    if($LoginAdmin == $ReAdmin)
    {
        $adminid = $item['id'];
        break;
    }
}

$LoginAdmin = find("SELECT * FROM `pre_admin` WHERE `id` = '$adminid'");

if(!$LoginAdmin)
{
    setcookie('LoginAdmin',null);
    ShowMsg('非法登录','login.php');
    exit;
}

?>
<div class="navbar">
    <div class="navbar-inner">
        <ul class="nav pull-right">
            <li>
                <a href="#" role="button">
                    <img width="20" src="<?php echo $LoginAdmin['avatar']; ?>" /><?php echo $LoginAdmin['username']; ?>
                </a>
            </li>
            <li>
                <a href="loginout.php" class="hidden-phone visible-tablet visible-desktop" role="button">Logout</a>
            </li>
        </ul>
        <a class="brand" href="index.php"><span class="second">Admin</span></a>
    </div>
</div>